﻿using System.Runtime.InteropServices;
using System.Web.UI;
using System.Web.UI.WebControls;
using Microsoft.SharePoint.WebControls;

namespace Practical.SharePoint.Base
{
    [Guid("6dde8121-765f-4cc3-9b69-4f9f7d84098a")]
// ReSharper disable InconsistentNaming
    public class jQueryLoader : WebControl
// ReSharper restore InconsistentNaming
    {
        protected override void CreateChildControls()
        {
            base.CreateChildControls();
            using (ScriptLink scriptLink = new ScriptLink())
            {
                scriptLink.OnDemand = false;
                scriptLink.LoadAfterUI = false;
                scriptLink.Localizable = false;
                scriptLink.Defer = false;
#if DEBUG
                scriptLink.Name = "~sitecollection/_layouts/Practical.SharePoint.Base/jquery-1.7.js";
#else
                scriptLink.Name = "~sitecollection/_layouts/Practical.SharePoint.Base/jquery-1.7.min.js";
#endif
                this.Controls.Add(scriptLink);
            }
        }
    }
}
